#ifndef FITRESULT_H
#define FITRESULT_H

#include <vector>
#include "Utility.h"
#include "../Include.h"

using namespace std;

namespace FitMethods {

    class AbsFitMethod;

    class FitResult {
        private:
            string name;
            vector <RooRealVar *> signal, background;
            vector <RooRealVar *> sigBelowIsolTh, bgdBelowIsolTh;
            double chiSquare;
        public:
            FitResult(string name, vector <RooRealVar *> signal, vector <RooRealVar *> background) {
                this->name=name; this->signal=signal; this->background=background;
                this->chiSquare=0;
            }
            void setSigBelowIsolTh(vector <RooRealVar *> sigBelowIsolTh) {
                this->sigBelowIsolTh = sigBelowIsolTh;
            }
            void setBgdBelowIsolTh(vector <RooRealVar *> bgdBelowIsolTh) {
                this->bgdBelowIsolTh = bgdBelowIsolTh;
            }
            void setChiSquare(double chiSquare) {
                this->chiSquare = chiSquare;
            }
            double getChiSquare() {
                return chiSquare;
            }
            string getName() {
                return name;
            }
            vector <RooRealVar *> getSignal() {
                return signal;
            }
            vector <RooRealVar *> getBackground() {
                return background;
            }
            void print() {
                for(vector <RooRealVar *>::iterator it = signal.begin();it!=signal.end();it++) (*it)->Print();
                for(vector <RooRealVar *>::iterator it = background.begin();it!=background.end();it++) (*it)->Print();
            }
            void dump(AnalysisResult::FitResult & result) {
                for(int num = 1;num<=(int)signal.size();num++) {
                    result.setSigCount(num,signal[num-1]->getVal());
                    result.setSigError(num,signal[num-1]->getError());
                }
                for(int num = 1;num<=(int)background.size();num++) {
                    result.setBgdCount(num,background[num-1]->getVal());
                    result.setBgdError(num,background[num-1]->getError());
                }
                for(int num = 1;num<=(int)sigBelowIsolTh.size();num++) {
                    result.setSigBelowIsolTh(num,sigBelowIsolTh[num-1]->getVal());
                }
                for(int num = 1;num<=(int)bgdBelowIsolTh.size();num++) {
                    result.setBgdBelowIsolTh(num,bgdBelowIsolTh[num-1]->getVal());
                }
                result.setFitChiSq(chiSquare);
            }
    };

}

#endif
